package com.sf.admin.controller;

import com.sf.admin.model.po.Role;
import com.sf.admin.model.vo.ServerInfo;
import com.sf.admin.moniter.MonitorService;
import com.sf.admin.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class PageController {

	@Autowired
	private MonitorService monitorService;

	@Autowired
	private RoleService roleService;

	@RequestMapping({"/","/index"})
	public String toIndex(){
		return "admin/index";
	}

	@RequestMapping("/welcome")
	public String toWelcome(Model model){
		// 获取服务器信息
		ServerInfo serverInfo = monitorService.getServerInfo();
		model.addAttribute("serveInfo",serverInfo);
		return "admin/welcome";
	}

	/**
	 * 跳转到角色页面
	 * @return
	 */
	@RequestMapping("/role")
	public String toRole(Model model){
		Integer pageNum = 0;
		Integer sizes = 10;
		List<Role> roleList = roleService.selectPages(pageNum, sizes);
		model.addAttribute("roleList",roleList);
		return "admin/rbac/rbac-role";
	}

	@RequestMapping("/menu")
	public String toMenu(){
		return "admin/menu1";
	}

	@RequestMapping("/sys/role/toAdd")
	public String toRoleAdd(){
		return "admin/rbac/role-add";
	}

	@RequestMapping("/sys/role/toEdit")
	public String toRoleEdit(){
		return "admin/rbac/role-edit";
	}

}
